/**
 * 获取当前对象距页面的边距 
 * @param object obj 对象
 * @return object 获取页面边距
 **/
function offset(obj) {
    var offset = { left: obj.offsetLeft, top: obj.offsetTop };
    var parent = obj.offsetParent;
    while (parent) {
        offset.left += parent.offsetLeft;
        offset.top += parent.offsetTop;
        parent = parent.offsetParent;
    }
    return offset;
}

function addClass(obj, className) {
    var name = obj.className.split(' ');
    if (name.indexOf(className) == -1) {
        name.push(className);
        obj.className = name.join(' ');
    }
}

function removeClass(obj, className) {
    var name = obj.className.split(' ');
    var index = name.indexOf(className);
    if (index != -1) {
        name.splice(index, 1);
        obj.className = name.join(' ');
    }
}